import 'package:flutter/widgets.dart';
import 'package:netease_cloud_music_api/utils/crypto.dart';
import 'package:netease_cloud_music_api/utils/player_request.dart';
import 'package:netease_cloud_music_api/utils/request.dart';

mixin Captcha {
  Future<PlayerRequestResponse> captchaSend({required int phone, int? countryCode}) {
    Map<String, dynamic> data = {'cellphone': phone, 'ctcode': countryCode ?? 86};
    return PlayerRequest(
      url: 'https://music.163.com/weapi/sms/captcha/sent',
      data: data,
      options: PlayerRequestOptions(
        method: PlayerRequestMethod.post,
        crypto: EncryptType.weapi,
      ),
    ).request();
  }

  Future<PlayerRequestResponse> captchaVerify({required int phone, required int captcha, int? countryCode}) {
    Map<String, dynamic> data = {'cellphone': phone, 'ctcode': countryCode ?? 86, 'captcha': captcha};
    return PlayerRequest(
      url: 'https://music.163.com/weapi/sms/captcha/verify',
      data: data,
      options: PlayerRequestOptions(
        method: PlayerRequestMethod.post,
        crypto: EncryptType.weapi,
      ),
    ).request();
  }
}
